﻿
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.V;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "详情";
    var _path = Url.Content("~/");
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    var Listitem = ViewBag.ItemList as List<Apps.Models.V_LMS_TESTDATA_CONFIRMEDModel>;/*TEST_TYPE>10*/
    var Checkitem = ViewBag.CheckList as List<Apps.Models.V_LMS_TESTDATA_CONFIRMEDModel>;/*TEST_TYPE = 0*/
    List<string> targets = ViewBag.Targets as List<string>;
}
<script type="text/javascript">
    function updateState(id, templateid, state) {
        if (state != 4) {
            var arr = new Array();
            $("input:checkbox:checked").each(function (index, obj) {
                arr.push($(obj).val());
            });
            var vals = arr.join(",");
            var time = '@Checkitem[0].UPDATE_TIME';
            //更新状态
            $.ajax({
                url: "@(_path)LMS/TestDataAudit/UpdateState",
                type: "Post",
                data: { id: id, templateid: templateid, approval_status: state, vals: vals, updatetime: time },
                dataType: "json",
                success: function (data) {
                    //window.parent.frameReturnByMes(data.message);
                    //window.parent.frameReturnByReload(true);
                    //window.parent.frameReturnByClose()
                    window.parent.ReturnByMes(data.message);
                    window.parent.ReturnByReload(true);
                    window.parent.ReturnByClose()
                }
            });
        } else {
            window.parent.ReturnByMes("操作成功");
            window.parent.ReturnByReload(true);
            window.parent.ReturnByClose()
        }
    }
</script>

<table border="1" style="width:100%;margin:10px 5px 0px 5px">
    <tbody>
        <tr>
            <td colspan="10" style="height:30px;font-size:20px;text-align:center">最终化验结果</td>
        </tr>
        @for (int i = 0; i <= Checkitem.Count / 5; i++)
        {
            <tr>
                @for (int j = 0; j < (Checkitem.Count - i * 5 >= 5 ? 5 : Checkitem.Count - i * 5); j++)
                {
                    <td style="width:150px">
                        @(Checkitem[5 * i + j].INDEX_NAME + Checkitem[5 * i + j].INDEX_DISNAME + "(" + Checkitem[5 * i + j].INDEX_UNIT + ")" )
                    </td>
                    <td>
                        <input class="easyui-textbox" type="text" name="name" style="width:100px" readonly="readonly" value="@Checkitem[5 * i + j].TEST_VALUE">
                    </td>
                }
            </tr>
        }
        <tr style="height:20px"></tr>
        <tr>
            <td colspan="10" style="height:30px;font-size:20px;text-align:center">复查化验结果</td>
        </tr>
        @for (int i = 0; i < targets.Count; i++)
        {
            var datas = Listitem.Where(a => a.INDEX_ID == targets[i]).OrderBy(a => a.TEST_TYPE).ToList();
            <tr>
                <th>
                    @(datas[0].INDEX_NAME + datas[0].INDEX_DISNAME + "(" + datas[0].INDEX_UNIT + ")")
                </th>
                <td colspan="10">
                    @for (int j = 0; j < datas.Count; j++)
                    {
                        @(datas[j].TEST_TYPE==0? "最终值:" + datas[j].TEST_VALUE : "第" + (datas[j].TEST_TYPE - 10) + "次化验值:" + datas[j].TEST_VALUE)
                        <input type="checkbox" name="@datas[j].INDEX_ID" value="@(datas[j].INDEX_ID + "_" + datas[j].CONFIRMED_ID)" onclick="return @ViewBag.IsShow==1?true:false;">

                        @* micyoo 注释 <input type="checkbox" name="@datas[j].INDEX_ID" value="@(datas[j].INDEX_ID + "_" + datas[j].CONFIRMED_ID)" onclick="return @ViewBag.IsShow==1?true:false;">*@

                    }
                </td>
            </tr>
        }
        <tr style="height:40px"></tr>
        <tr>
            <td colspan="10" style="height:500px;position:relative">
                <div class="easyui-tabs" id="ListTab" style="position:absolute;top:0;bottom:0;left:0;right:0;height:100%" onselect="BindData();">
                    <div title="公式" style="padding:10px">
                        <img src="~/Image/mathematical.jpg" height="450" />
                    </div>
                    @for (int i = 0; i < Checkitem.Count; i++)
                    {
                        <div title="@Checkitem[i].INDEX_DISNAME" style="padding:10px">
                            <table id="@("List"+i)" style="width:100%"></table>
                        </div>
                    }
                </div>
            </td>
        </tr>
    </tbody>
</table>

<script>
    $(function () {
        $('#ListTab').tabs({
            border: false,
            fit: true,
            onSelect: function (title, index) {
                if (index == 0) {
                    return;
                } else {
                    var listId = "#List" + (index - 1);
                    var name = @ViewBag.TEST_CODE + "_" + title;
                    $(listId).datagrid({
                        url: '@Url.Action("GetNatureList")?&index_disname=' + name,
                        //width: SetGridWidthSub(40),
                        methord: 'post',
                        height: 450,
                        fitColumns: true,
                        sortName: 'TEST_TIME',
                        sortOrder: 'desc',
                        idField: 'COLLECTION_ID',
                        pageSize: 15,
                        pageList: [15, 20, 30, 40, 50],
                        pagination: false,
                        striped: true, //奇偶行是否区分
                        singleSelect: true,//单选模式
                        checkOnSelect: false,
                        selectOnCheck: false,
                        rownumbers: true,//行号
                        onLoadSuccess: function (data) {
                        },
                        columns: [[
                            { field: 'INDEX_DISNAME', title: '化验指标', width: 120, sortable: true },
                            { field: 'TEST_VALUE', title: '化验结果', width: 100, sortable: true },
                            { field: 'STATUS_STR', title: '化验状态', width: 80 },
                            { field: 'TEST_TIME', title: '化验时间', width: 80 }
                        ]]
                    });
                }
            }

        });
    });
</script>
